package com.fcscs.cservice.service;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.fcscs.cservice.common.CServiceCommonUtils.NotifEntityIntf;
import com.fcscs.cservice.domain.model.CheckInConfiguration;
import com.fcscs.cservice.domain.model.CheckOutConfiguration;
import com.fcscs.cservice.domain.model.FolioView;
import com.fcscs.cservice.domain.model.FolioViewForFile;
import com.fcscs.cservice.domain.model.MessageIdAndStatus;
import com.fcscs.cservice.domain.model.MessageView;
import com.fcscs.cservice.domain.model.RCView;
import com.fcscs.cservice.domain.model.RCViewForFile;
import com.fcscs.cservice.domain.model.ReservationConf;
import com.fcscs.cservice.domain.model.ReservationView;

@Service
public interface ReservationManager {

	/**
	 * find reservations (simple search)
	 * @param propId property id
	 * @param term term to search in first name, last name, confirmation no
	 * @param rsvStatusId reservation status id
	 * @param startTime startTime to look for in Server timezone
	 * @param endTime endTime to look for in Server timezone
	 * @param start 0 based start index
	 * @param resultCnt max result count limit
	 * @return
	 */
	List<ReservationView> findReservations(long propId, String term, Long rsvStatusId, Date startTime, Date endTime,
			int start, int resultCnt);

	/**
	 * total of find reservations result (simple search)
	 * @param propId propertyId
	 * @param term term to search in first name, last name, confirmation no
	 * @param rsvStatusId reservation status id
	 * @param startTime startTime to look for in Server timezone
	 * @param endTime endTime to look for in Server timezone
	 * @return
	 */
	int findReservationsCnt(long propId, String term, Long rsvStatusId, Date startTime, Date endTime);

	/**
	 * find reservations (advanced search)
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatus reservation status id
	 * @param roomNo room no
	 * @param memberNo membership no
	 * @param roomStatus room status id
	 * @param baggageNo baggage no
	 * @param arrivDate arrival date
	 * @param departDate departure date
	 * @param eta expected arrival time
	 * @param etd expected departure time
	 * @param startTime startTime to look for in Server timezone
	 * @param endTime endTime to look for in Server timezone
	 * @param start 0 based start index
	 * @param resultCnt max result count limit
	 * @return
	 */
	List<ReservationView> findReservations(long propId, String firstName, String lastName, Long rsvStatus, String roomNo, 
			String memberNo, Long roomStatus, String baggageNo, Date arrivDate, Date departDate, Date eta, Date etd, 
			Date startTime, Date endTime, int start, int resultCnt);

	/**
	 * total of find reservations result (advanced search)
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatus reservation status id
	 * @param roomNo room no
	 * @param memberNo membership no
	 * @param roomStatus room status id
	 * @param baggageNo baggage no
	 * @param arrivDate arrival date
	 * @param departDate departure date
	 * @param eta expected arrival time
	 * @param etd expected departure time
	 * @param startTime startTime to look for in Server timezone
	 * @param endTime endTime to look for in Server timezone
	 * @return
	 */
	int findReservationsCnt(long propId, String firstName, String lastName, Long rsvStatus, String roomNo, 
			String memberNo, Long roomStatus, String baggageNo, Date arrivDate, Date departDate, Date eta, Date etd,
			Date startTime, Date endTime);

	/**
	 * search reservations for folio page
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatusId reservation status id
	 * @param roomNo room no
	 * @param arrivStart arrival start date (time should be 00:00:00 at client end)
	 * @param arrivEnd arrival end date (time should be 23:59:59 at client end)
	 * @param departStart departure start date (time should be 00:00:00 at client end)
	 * @param departEnd departure end date (time should be 23:59:59 at client end)
	 * @param date current day (time should be 00:00:00 at client end)
	 * @param start 0 based start index
	 * @param resultCnt max result count limit
	 * @return
	 */
	List<ReservationView> findRsvForFolio(long propId, String firstName, String lastName, Long rsvStatusId, String roomNo,
			Date arrivStart, Date arrivEnd, Date departStart, Date departEnd, Date date, int start, int resultCnt);

	/**
	 * search reservations for folio page
	 * @param propId property id
	 * @param firstName guest first name
	 * @param lastName guest last name
	 * @param rsvStatusId reservation status id
	 * @param roomNo room no
	 * @param arrivStart arrival start date (time should be 00:00:00 at client end)
	 * @param arrivEnd arrival end date (time should be 23:59:59 at client end)
	 * @param departStart departure start date (time should be 00:00:00 at client end)
	 * @param departEnd departure end date (time should be 23:59:59 at client end)
	 * @param date current day (time should be 00:00:00 at client end)
	 */
	int findRsvForFolioCnt(long propId, String firstName, String lastName, Long rsvStatusId, String roomNo,
			Date arrivStart, Date arrivEnd, Date departStart, Date departEnd, Date date);

	/**
	 * get ReservationView by id
	 * @param id
	 * @return
	 */
	ReservationView getReservationView(long id);

	/**
	 * get RCView by id. This api is for UI display, will call getRCView(id, true)
	 * @param id
	 * @param userName current user login name
	 * @return
	 */
	RCView getRCView(long id, String userName);

	/**
	 * get RCView by id. This api is for generating pdf
	 * @param id
	 * @return
	 */
	RCViewForFile getRCViewForFile(long id);

	/**
	 * update rc content
	 * @param rc rc to be updated
	 * @param initial TODO
	 * @param signature TODO
	 * @return
	 */
	RCView updateRCView(RCView rc, byte[] initial, byte[] signature);
	
	/**
	 * get folio by id
	 * @param id
	 * @return
	 */
	FolioView getFolioView(long id);
	
	/**
	 * get folio by id
	 * @param id
	 * @return
	 */
	FolioViewForFile getFolioViewForFile(long id);

	/**
	 * get all messages of a reservation
	 * @param rsvId reservation id
	 * @return
	 */
	List<MessageView> getMessages(long rsvId);

	/**
	 * update message isRead status
	 * @param messageList
	 * @return
	 */
	List<MessageIdAndStatus> updateMessages(List<MessageIdAndStatus> messageList);

	/**
	 * process an express check in
	 * @param rsvId reservation id
	 * @param rc rc with guest signature
	 * @return
	 */
	boolean expressCheckIn(long rsvId, RCView rc);

	/**
	 * process check out
	 * @param isAuto true: auto check out; false: manual check out
	 * @param folioId TODO
	 * @param signature TODO
	 * @param paymentMethodId TODO
	 * @param remarks TODO
	 * @return
	 */
	boolean checkOut(boolean isAuto, long folioId, byte[] signature, long paymentMethodId, String remarks);

	/**
	 * send a copy of folio after successfully auto checked out
	 * @param rsvId reservation id
	 * @param folioId folio id
	 * @return
	 */
	boolean sendEFolio(long rsvId, long folioId);

	ReservationConf getRsvConf(long orgId, long propId);

	ReservationConf saveRsvConf(ReservationConf conf);

	CheckInConfiguration getCheckInConf(long orgId, long propId);

	CheckInConfiguration saveCheckInConf(CheckInConfiguration conf);

	CheckOutConfiguration getCheckOutConf(long orgId, long propId);

	CheckOutConfiguration saveCheckOutConf(CheckOutConfiguration conf);

	NotifEntityIntf getRsvNotifEntity(ReservationView rv);

	ReservationView getCurReservationViewByGP(long gpId);
}
